require 'watir'
include Watir
require 'test/unit'
require 'test/unit/ui/console/testrunner'
require 'watir/testUnitAddons'
require 'watir/testcase'
require 'watir/contrib/enabled_popup'
class TC_Forums < Test::Unit::TestCase
  def test_14
=begin
    $ie.goto($UniVar)
    $ie.refresh()

    $ie.link(:text, 'Control Panel').click
    $ie.link(:text, 'Administration').click
    $ie.table(:index, 7).click
    $ie.link(:index, 13).click
    $ie.wait()
    $ie.text_field(:index, 1).value = "temp forum"
    $ie.link(:text, 'Save').click
    $ie.link(:text, 'Exit Control Panel and Return to Site').click

    $ie.link(:text, 'Forums').click
    assert($ie.link(:text, 'temp forum').exists?)
    $ie.link(:text, 'temp forum').click
    $ie.link(:text, 'Write a New Post').click
    $ie.text_field(:index, 2).value = "temp subject"
    temp_var = "temp body"
    $ie.ie.Document.parentWindow.execScript("tinyMCE.getInstanceById(tinyMCE.getEditorId('mce_editor_0')).execCommand('mceSetContent', false, '" + temp_var + "')")        

#    $ie.button(:id, /ctl00_ctl00_bcr_bcr_PostForm_ctl04_PostButton/).click
    $ie.button(:id, /ctl00_ctl01_bcr_PostForm___PostButton/).click



    $ie.link(:text, 'Reply').click
    temp_var = "temp body first reply"
    $ie.ie.Document.parentWindow.execScript("tinyMCE.getInstanceById(tinyMCE.getEditorId('mce_editor_0')).execCommand('mceSetContent', false, '" + temp_var + "')")            
    
#    $ie.button(:id, /ctl00_ctl00_bcr_bcr_PostForm_ctl04_PostButton/).click
    $ie.button(:id, /ctl00_ctl01_bcr_PostForm___PostButton/).click



    $ie.link(:text, 'Reply').click
    temp_var = "temp body second reply"
    $ie.ie.Document.parentWindow.execScript("tinyMCE.getInstanceById(tinyMCE.getEditorId('mce_editor_0')).execCommand('mceSetContent', false, '" + temp_var + "')")            
    
#    $ie.button(:id, /ctl00_ctl00_bcr_bcr_PostForm_ctl04_PostButton/).click
    $ie.button(:id, /ctl00_ctl01_bcr_PostForm___PostButton/).click
    
    assert($ie.link(:text, 'Moderate').exists?)
    $ie.link(:text, 'Moderate').click
    $ie.cell(:index, 42).click
    temp_var = "lets change the content"
    $ie.ie.Document.parentWindow.execScript("tinyMCE.getInstanceById(tinyMCE.getEditorId('mce_editor_0')).execCommand('mceSetContent', false, '" + temp_var + "')")            
    $ie.text_field(:index, 4).value = "Edit the Notes"
#    $ie.button(:id, /ctl00_ctl00_bcr_bcr_PostForm_ctl04_PostButton/).click
    $ie.button(:id, /ctl00_ctl01_bcr_PostForm___PostButton/).click
    assert($ie.contains_text(temp_var))
    $ie.link(:text, 'Moderate').click
    $ie.cell(:index, 43).click
    
=end
    $ie.goto('http://localhost/cs/controlpanel/Moderation/DeletePost.aspx?PostID=103&q=childposts&ReturnUrl=%2fcs%2fforums%2f74%2fShowForum.aspx')
    puts $ie.html()
#    $ie.elementCollections.each do |i|
#      begin
#      i.flash 
#    end
#  end
  

#    $ie.select_list(:id, /ctl01_ctl01_TaskRegion_ctl00___ReasonTemplate/).select("Incomprehensible Post")
#    $ie.wait()
#    assert($ie.text_field(:index, 1).value = "All posts to the Community Server Forums must be in English")
=begin
    
    $ie.select_list(:id, /ctl01_ctl01_TaskRegion_ctl00___ReasonTemplate/).select("Non-English Post")
    $ie.wait()
    assert($ie.text_field(:index, 1).value = "Unfortunately your post does not make sense")


    $ie.select_list(:id, /ctl01_ctl01_TaskRegion_ctl00___ReasonTemplate/).select("Off-Topic Post")
    $ie.wait()
    assert($ie.text_field(:index, 1).value = "Your message is unrelated to the topic of the Community Server Forums")


    $ie.text_field(:index, 1).clear
    $ie.text_field(:index ,1).value = "Its just a bad post"

#    $ie.button(:id, /ctl01_ctl01_TaskRegion_ctl00_DeletePost/).click_no_wait
    $ie.button(:id, /ctl01_ctl01_TaskRegion_ctl00___DeletePost/).click_no_wait
    hwnd = $ie.enabled_popup(20)
      if(hwnd)
        w = WinClicker.new
          w.clickWindowsButton_hwnd(hwnd, "OK")
        end
        
        assert(!$ie.link(:text, 'temp subject'))
    
    $ie.link(:text, 'Community Server')
    $ie.link(:text, 'Deleted Posts').click
    assert($ie.link(:text, 'temp subject').exists?)
    
    
    
    
    
      $ie.goto($UniVar + '/controlpanel/forums/Forums.aspx')
      $ie.div(:index, 62).click
      $ie.div(:index, 62).click    
      $ie.link(:text, 'Delete').click_no_wait
      hwnd = $ie.enabled_popup(20)
        if(hwnd)
          w = WinClicker.new
          w.clickWindowsButton_hwnd(hwnd, "OK")
        end
=end
  end
end